package com.lingchen.boot.controller;

import com.lingchen.boot.pojo.User;
import com.lingchen.boot.service.UserService;
import com.lingchen.boot.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * I'm a cute code dog
 * User: LingChen
 * Date:2018/2/6
 * Time:18:19
 */
@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("/login")
    public String loginPage() {
        userService.batchInsert();
        System.out.println("users");
        return "login";
    }

    @PostMapping("/login")
    @ResponseBody
    public Result login(@RequestParam String account,
                        @RequestParam String password) {
        System.out.println(account);
        System.out.println(password);

        return new Result(0, "ok", null);
    }


    @RequestMapping("/test")
    @ResponseBody
    public String test() {
        List<User> all = userService.findAll();
        System.out.println(all);
        return "test";
    }



}
